import React from 'react'
import { withRouter } from 'react-router-dom'
import { connect } from 'react-redux'
import { logoutAction } from '../actions/login-action'
import { bindActionCreators } from 'redux'

@connect(
	state => ({}),
	dispatch => ({
		logoutAction: bindActionCreators(logoutAction, dispatch)
	})
)
class Logout extends React.Component {
	componentWillMount() {
		sessionStorage.clear()
		this.props.logoutAction()
	}

	componentDidMount() {
		this.props.history.replace("/login")
	}

	render() {
		return null
	}
}

export default withRouter(Logout)